var class_num=location.search;
class_num=class_num.split('?')[1];
$('#href_index').attr('href','course.html?'+class_num);
$('#href_message').attr('href','message.html?'+class_num);
$('#me').attr('href','me.html?'+class_num);
if (islogin()) {
    $.post({
        url:'../../requests/student/select_teacher_name.php',
        data:{'class':class_num},
        success:function (data) {
            $('.teacher_name').text(data.teacher_name);
        }
    });

    $('#add').click(function () {
        var title=$("input[name='title']").val();
        var detail=$("textarea[name='detail']").val();
        if (title == "") {
            $$.alert("标题不能为空！");
        }
        else {
            $.post({
                url:'../../requests/student/add_message.php',
                data:{'title':title,'detail':detail,'class':class_num},
                success:function (data) {
                    if (data == '1') {
                        $$.alert("留言成功！",function () {
                            window.history.go(-1);
                        });
                    }
                    else if (data == '0') {
                        $$.alert("留言失败！")
                    }
                }
            });
        }
    });
}
else window.location.href='../../index.html';